Developer Documentation

QuickTime 4 API Documentation

Inside Macintosh: Files

Previous | Chapter Top | Chapter Contents

Application Launch File Routines

You can call GetAppParms to determine your application's name and the reference number of its resource file. When your application starts up, you can call CountAppFiles to determine whether the user selected any documents to open or print. If so, you can call GetAppFiles and ClrAppFiles to process the information passed to your application by the Finder.

If your application supports high-level events, you receive this information from the Finder in an Open Documents or Print Documents event.

GetAppParms

You can use the GetAppParms procedure to get information about the current application and about files selected by the user for opening or printing.

PROCEDURE GetAppParms(VAR apName: Str255; VAR apRefNum: Integer;
                                          VAR apParam: Handle);
apName
On output, the name of the calling application.
apRefNum
On output, the reference number of the application's resource file.
apParam
On output, a handle to the Finder information about files to open or print.

DESCRIPTION

The GetAppParms procedure returns information about the current application. You can call GetAppParms at application launch time to determine which files, if any, the user has selected in the Finder for opening or printing. You can call GetAppParms at any time to determine the current application's name and the reference number of the application's resource fork.

The GetAppParms procedure returns the application's name in the apName parameter and the reference number of its resource fork in the apRefNum parameter. A handle to the Finder information is returned in apParam . This information consists of a word that encodes the message or action to be performed, a word that indicates how many files to process, and a list of Finder information about each such file. The Finder information has the structure of an AppFile record, except that the filename occupies only as many bytes as are required to hold the name (padded to an even number of bytes, if necessary). In general, it is easier to use the GetAppFiles procedure to access the Finder information.

SPECIAL CONSIDERATIONS

If you simply want to determine the application's resource file reference number, you can call the Resource Manager function CurResFile when your application starts up.

If you need more extensive information about the application than GetAppParms provides, you can use the Process Manager function GetCurrentProcess .

ASSEMBLY-LANGUAGE INFORMATION

You can get the application's name, reference number, and handle to the Finder information directly from the global variables CurApName , CurApRefNum , and AppParmHandle .

CountAppFiles

You can use the CountAppFiles procedure to determine how many documents (if any) the user has selected at application launch time for opening or printing.

PROCEDURE CountAppFiles (VAR message: Integer;
                                          VAR count: Integer);
message
The action to be performed on the selected files.
count
The number of files selected.

DESCRIPTION

The CountAppFiles procedure deciphers the Finder information passed to your application and returns information about the files that were selected when your application was started up. On exit, the count parameter contains the number of selected files, and the message parameter contains an integer that indicates whether the files are to be opened or printed. The message parameter contains one of these constants:

CONST
    appOpen     =   0;      {open the document(s)}
    appPrint    =   1;      {print the document(s)}

GetAppFiles

You can use the GetAppFiles procedure to retrieve information about each file selected at application startup for opening or printing.

PROCEDURE GetAppFiles (index: Integer; VAR theFile: AppFile);
index
The index of the file whose information is returned.
theFile
A structure containing the returned information.

DESCRIPTION

The GetAppFiles procedure returns information about a file that was selected when your application was started up (as listed in the Finder information). The index parameter indicates the file for which information should be returned; it must be between 1 and the number returned by CountAppFiles , inclusive.

ClrAppFiles

You can use the ClrAppFiles procedure to notify the Finder that you have processed the information about a file selected for opening or printing at application startup.

PROCEDURE ClrAppFiles (index: Integer);
index
The index of the file whose information is to be cleared.

DESCRIPTION

The ClrAppFiles procedure changes the Finder information passed to your application about the specified file so that the Finder knows you've processed the file. The index parameter must be between 1 and the number returned by CountAppFiles , inclusive. You should call ClrAppFiles for every document your application opens or prints, so that the information returned by CountAppFiles and GetAppFiles is always correct. The ClrAppFiles procedure sets the file type in the Finder information to 0.

 


© 1997 Apple Computer, Inc.

Previous | Chapter Top | Chapter Contents